import { sendToContentScript } from "@plasmohq/messaging"

import useObserver from "@/hooks/useObserver"

const observer = useObserver()

/**
 * 检查天眼查是否登录，未登录则前往登录
 */
observer.add(async () => {
  const authToken = await chrome.cookies.get({ url: "https://www.tianyancha.com", name: "auth_token" })
  if (authToken) return
  await chrome.tabs.create({ url: "https://www.tianyancha.com/login", active: true })
})

observer.notify()
